package calorie.com.calorie.contact;

import android.content.Context;


import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;


import calorie.com.calorie.api.ApiService;
import calorie.com.calorie.constant.Constant;
import calorie.com.calorie.response.TodayProfitResponce;
import retrofit2.Call;
import retrofit2.Response;

public class IncomeStastisticsContact {
    public static class IncomeStastisticsPresent extends BasePresent<IIncomeStastisticsView>{
        public void getTodayProfit(Context context){
            ApiService service= ServiceGenerator.createService(ApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            service.getTodayProfit(userId).enqueue(new NetCallBack<TodayProfitResponce>() {
                @Override
                public void onSuccess(Call<TodayProfitResponce> call, Response<TodayProfitResponce> response) {
                    if (getView()!=null){
                        getView().getTodayProfitData(response);
                    }
                }

                @Override
                public void onFailed() {
                   // ToastUtils.showLongToast(context,"网络请求异常");
                }
            });
        }
    }
    public interface IIncomeStastisticsView extends IBaseView{
        void getTodayProfitData(Response<TodayProfitResponce> response);
    }
}
